﻿var viewPartialModel = new function () {
    // keypress enter
    this.FieldName = ko.observable((data != undefined && data!= null && data.FieldName != null) ? data.FieldName : "Title");
    this.Keywords = ko.observable((data != undefined && data != null && data.Keywords != null) ? data.Keywords : "Keywords");

    this.RunSomethingKey = function (viewModel, event) {
        if (event.keyCode == 13) {
            this.RunSomething(viewModel, event);
        }
        return true;
    }
    this.RunSomething = function (viewModel, event) {
        RelocatePress();
    }
    this.FindData = function () {
        RelocatePress();
    }
    function RelocatePress() {
        var keywords = $('#keywords').val();
        if (keywords.toLowerCase() == "keywords")
            keywords = "";

        var fields = $('#selectFields').val()

        if (keywords != "") {
            window.location.href = '/MyAccount/ProductList/Search?keywords=' + keywords + '&fieldName=' + fields;
        }
    }
};

ko.applyBindings(viewPartialModel, document.getElementById("header"));